package com.neusoft.bizcore.license.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import com.neusoft.bizcore.license.interceptor.LicenseCheckInterceptor;

@Configuration
@ComponentScan("com.neusoft.bizcore.license")
public class BizcoreLicenseConfiguration implements WebMvcConfigurer {

    @Bean
    public LicenseCheckInterceptor getLicenseCheckInterceptor() {
        return new LicenseCheckInterceptor();
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(this.getLicenseCheckInterceptor())
                .addPathPatterns(new String[] {"/**" })
                .excludePathPatterns(
                        new String[] {"/error", "/swagger-resources/**", "/csrf", "/licenses/**" });
    }

}
